//
//  MRNewNotificationDateSelectCell.m
//  MoRan
//
//  Created by MoRan Team on 2023.
//  Copyright © 2023 MoRan Team. All rights reserved.
//

#import "MRNewNotificationDateSelectCell.h"

@implementation MRNewNotificationDateSelectCell 

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    _myButton.adjustsImageWhenHighlighted = NO;
}

- (void)setData:(id)data delegate:(id)delegate {
    _delegate = delegate;
    
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[MRNewNotificationDateSelectCellModel class]]) {
            MRNewNotificationDateSelectCellModel *model = data[@"data"];
            _model = model;
            _titleLabel.text = model.title;
            
            if ([model.title isEqualToString:@"预计总金额"]) {
                self.tag = 10000;
                _myButton.hidden = YES;
            } else {
                _myButton.hidden = NO;
                self.tag = 10001;
            }
            
            if (model.content.length > 0) {
                _contentLabel.text = model.content;
                _contentLabel.textColor = UIColorFromHex(0x11100D);
            } else {
                if ([model.title isEqualToString:@"预计总金额"]) {
                    _contentLabel.text = @"￥0.00";
                } else {
                    _contentLabel.text = @"请选择时间";
                }
                _contentLabel.textColor = UIColorFromHex(0x999999);
            }
        }
    }
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(newNotificationDateSelectCell:buttonAction:)]) {
        [_delegate newNotificationDateSelectCell:self buttonAction:sender];
    }
}

@end


#pragma mark - Model

@implementation MRNewNotificationDateSelectCellModel

+ (MRNewNotificationDateSelectCellModel *)ittemModelWithTitle:(NSString *)title content:(NSString *)content {
    MRNewNotificationDateSelectCellModel *model = [MRNewNotificationDateSelectCellModel new];
    model.title = kSafeString(title);
    model.content = kSafeString(content);
    return model;
}

@end
